﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.AspNet.FriendlyUrls;

#endregion

namespace WinnerCMS.WebUI
{
    public static class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            //var settings = new FriendlyUrlSettings
            //{
            //    AutoRedirectMode = RedirectMode.Permanent
            //}; 
            //routes.EnableFriendlyUrls(settings);


            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            // Turns off the unnecessary file exists check
            //routes.RouteExistingFiles = true;


            // Ignore the directory which contains images, js, css & html
            routes.IgnoreRoute("UpLoadFolder/{*pathInfo}");
            routes.IgnoreRoute("Content/{*pathInfo}");
            routes.IgnoreRoute("Scripts/{*pathInfo}");

            routes.IgnoreRoute("{*fileType}",
                new {fileType = @".*\.(gif|js|jpg|css|png|xml|ico|swf|jpeg|bmp|asp|jsp|php|rar)(/.*)?"});


            // 对{folder}/{webform}形式的URL进行路由
            routes.MapPageRoute("UserMap", "User/{webform}.aspx", "~/Templates/WinnerCMS6/Member/{webform}.aspx");
            routes.MapPageRoute("GuestbookMap", "Guestbook.aspx", "~/Templates/WinnerCMS6/Guestbook.aspx");

            routes.MapRoute("CategoryPage", "Category/{CategoryId}/{PageNo}",
                new { controller = "Category", action = "Index", PageNo = 1 }, new { CategoryId = @"\d+", PageNo = @"\d+" }
                );

            routes.MapRoute("ShowPage", "{controller}/{action}/{ID}/{PageNo}",
                new {controller = "Article", action = "Show", PageNo = UrlParameter.Optional},
                new { PageNo = @"\d+", ID = @"\d+" }
                );

            // routes.MapRoute(
            //    name: "actionPage",
            //    url: "{action}",
            //    defaults: new { controller = "Default", action = "Index" }
            //);

            routes.MapRoute("Default", "{controller}/{action}", new {controller = "Default", action = "Index"}
                );
        }
    }
}